package com.example.lasttrain;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.Window;

public class SplashActivity extends Activity {	
	
	boolean checkTouched = false;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {		
		super.onCreate(savedInstanceState);				
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.splash);
		Handler hdl = new Handler();
		hdl.postDelayed(new splashHandler(), 3000);
		
	}
	class splashHandler implements Runnable {
		public void run() {
			if (checkTouched) return; //duplicated list activity
			
			Intent i = new Intent(getApplication(), ListActivity.class);
			startActivity(i);
			SplashActivity.this.finish();
		}		
	}	
	
	/** 画面タッチ時のクラス */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
//        Log.d("TouchEvent", "X:" + event.getX() + ",Y:" + event.getY());
    	
    	if(checkTouched) return false;
    	
        Intent intent = new Intent(getApplication(), ListActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        startActivity(intent);
        
        checkTouched = true;
        finish(); //duplicated list activity
        return true;
    }
}